package com.moorror.codegenvel.db.sqlite.entity;

import com.moorror.codegenvel.utils.JacksonUtils;
import lombok.Getter;
import lombok.Setter;

/**
 * @Author jiyanghuang
 * @Date 2025/8/15 23:00
 */
public class CodeGenTemplate extends AbEntity {

    private String name;

    /**
     * 类似备注
     */
    private String descTemplate;

    private String content;

    /**
     * json 上下文
     * 模板本身独有的
     */
    private String jsonContext;


    /**
     * 该字段后面都是在场景下的扩展字段
     * 冗余
     * 最终文件名
     */
    private String fileName;

    /**
     * 冗余
     * 保存的路径
     */
    private String savePath;

    /**
     * 当前是否跳过生成
     */
    private boolean skipGenCode = false;

    /**
     * 覆盖时是否提示
     */
    private boolean coverPrompt = true;


    /**
     * 默认的生成顺序是100
     * 越小越早生成
     */
    @Getter
    @Setter
    private String orderGen = "100";

    public void fillJsonValue(CodeGenTemplate jsonValue){
        this.fileName = jsonValue.fileName;
        this.savePath =  jsonValue.savePath;
        this.skipGenCode = jsonValue.skipGenCode;
        this.coverPrompt = jsonValue.coverPrompt;
        this.orderGen = jsonValue.orderGen;
    }

    @Override
    public String fetchJsonValueNToMN() {
        CodeGenTemplate codeGenTemplate = new CodeGenTemplate();
        codeGenTemplate.setFileName(this.fileName);
        codeGenTemplate.setSavePath(this.savePath);
        codeGenTemplate.setSkipGenCode(this.skipGenCode);
        codeGenTemplate.setCoverPrompt(this.coverPrompt);
        codeGenTemplate.setOrderGen(this.orderGen);
        return JacksonUtils.toJSONString(codeGenTemplate);
    }

    @Override
    public String uniqueKey() {
        return name;
    }

    public static CodeGenTemplate of(String name) {
        CodeGenTemplate codeGenTemplate = new CodeGenTemplate();
        codeGenTemplate.setName(name);
        return codeGenTemplate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescTemplate() {
        return descTemplate;
    }

    public void setDescTemplate(String descTemplate) {
        this.descTemplate = descTemplate;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getSavePath() {
        return savePath;
    }

    public void setSavePath(String savePath) {
        this.savePath = savePath;
    }

    public String getJsonContext() {
        return jsonContext;
    }

    public void setJsonContext(String jsonContext) {
        this.jsonContext = jsonContext;
    }

    public boolean isSkipGenCode() {
        return skipGenCode;
    }

    public void setSkipGenCode(boolean skipGenCode) {
        this.skipGenCode = skipGenCode;
    }

    public boolean isCoverPrompt() {
        return coverPrompt;
    }

    public void setCoverPrompt(boolean coverPrompt) {
        this.coverPrompt = coverPrompt;
    }
}
